package com.txts.road.app.message.controller;

import com.txts.road.app.message.service.AppMessageService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.txts.road.app.message.model.dto.MessageDTO;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 消息前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:46
 */
@Tag(name = "消息接口")
@RestController
@RequestMapping("/api/v1/message")
@RequiredArgsConstructor
public class AppMessageController {
    private final AppMessageService appMessageService;

    /**
     * 发送消息
     */
    @Operation(summary = "发送消息")
    @PostMapping("/send")
    public ResponseDTO<Long> sendMessage(@RequestBody MessageDTO sendDTO) {
        return ResponseDTO.ok(appMessageService.sendMessage(sendDTO));
    }

    /**
     * 标记消息已读
     */
    @Operation(summary = "标记消息已读")
    @PutMapping("/read")
    public ResponseDTO<Boolean> markMessageRead(@RequestBody List<Long> sessionIds) {
        return ResponseDTO.ok(appMessageService.markMessageRead(sessionIds));
    }


}
